package com.chat.view;

import com.chat.Local;
import com.chat.service.DelFriend;
import com.chat.service.GetFriendMessage;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.text.Text;
import javafx.stage.Stage;


import java.io.File;

/*
  好友详细信息的Controller
 */
public class FriendMsgController {
    public Label test;
    public Text nickname;
    public Text sex;
    public Text username;
    public Text mailbox;
    public Text borndate;
    public Text qianming;
    public ImageView touxiang;


    public void initialize(){
        GetFriendMessage gfm=new GetFriendMessage();
        gfm.getfriendmessage();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        File file1=new File("D:/chatproject/client/"+Local.friend.getUsername()+".png");
        touxiang.setImage(new Image("file:"+file1.getAbsolutePath()));
        nickname.setText(Local.friend.getNickname());
        sex.setText(Local.friend.getSex());
        username.setText(Local.friend.getUsername());
        mailbox.setText(Local.friend.getMailbox());
        borndate.setText(Local.friend.getBorndate().toString());
        qianming.setText(Local.friend.getQianming());
    }
    public void del_friend(){//删除好友按钮的点击事件
        DelFriend df=new DelFriend();
        df.delfriend(Local.user.getUsername(),Local.friend.getUsername());
        Stage stage=(Stage) qianming.getScene().getWindow();
        stage.close();
    }
    public void tuichu(){//退出按钮的点击事件
        Stage stage=(Stage) qianming.getScene().getWindow();
        stage.close();
    }
    public void smallest(){//最小化
        FriendMsgView.loginStage.setIconified(true);

    }
}
